package com.future.mayi.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.future.mayi.R;
import com.future.mayi.model.interfaces.DialogEnterListener;

/**
 * Created by 周大虎 on 2018/3/9.
 */

public class ClearCacheDialog extends Dialog {


    private Object tag;

    public ClearCacheDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        setCancelable(false);
        init(context);
    }
    private DialogEnterListener listener;

    private void init(Context context) {
        View layout = LayoutInflater.from(context).inflate(R.layout.dialog_clear_cache, null);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        setContentView(layout, params);
        findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null)
                    listener.cancel(tag);

            }
        });
        findViewById(R.id.tv_enter).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null)
                    listener.enter(tag);

            }
        });
    }


    public void setListener(DialogEnterListener listener) {
        this.listener = listener;
    }

    public void setTag(Object tag) {
        this.tag = tag;
    }
}
